#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>

#define BUFF_SIZE 1024

int main()
{
    int sock = socket(AF_INET, SOCK_STREAM, 0);

    struct sockaddr_in sock_addr;
    sock_addr.sin_family = AF_INET;
    sock_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
    sock_addr.sin_port = htons(1234);
    connect(sock, (struct sockaddr*)&sock_addr, sizeof(sock_addr));

    char buffSend[BUFF_SIZE] = {0};
    printf("Please input a string: ");
    scanf("%s", buffSend);
    send(sock, buffSend, strlen(buffSend), 0);

    char buffRecv[BUFF_SIZE] = {0};
    recv(sock, buffRecv, BUFF_SIZE, 0);
    printf("Message from server: %s\n", buffRecv);

    close(sock);

    return 0;
}